using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EnemyAnimationTrigger : MonoBehaviour
{
    public Enemy enemy => GetComponentInParent<Enemy>();

    void AnimationTrigger()
    {
        enemy.AnimationTrigger();
    }


    private void AttackTrigger()
    {        
        AudioManager.Instance.PlaySound((int)E_SoundType.SkeleAttack, gameObject.AddComponent<AudioSource>());
        Collider2D[] colliders = Physics2D.OverlapCircleAll(enemy.attackCheck.position, enemy.attackRadius);
        foreach (var collider in colliders)
        {
            PlayerData player = collider.GetComponent<PlayerData>();
            if (player != null)
            {
                enemy.data.DoDamage(player);
            }
        }
    }

    void OpenCounterWindow() => enemy.OpenCounterWindow();


    void CloseCounterWindow() => enemy.CloseCounterWindow();

}
